package cn.ava.ymcc.feign.fallback;

import cn.ava.ymcc.doc.CourseDoc;
import cn.ava.ymcc.feign.SearchFeignClient;
import cn.ava.ymcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class SearchFeignClientFallbackFactory implements FallbackFactory<SearchFeignClient> {

    @Override
    public SearchFeignClient create(Throwable cause) {
        return new SearchFeignClient() {
            @Override
            public JSONResult saveCourse(CourseDoc doc) {
                cause.printStackTrace();
                return JSONResult.error("搜索管理中心服务不可用!");
            }
            @Override
            public JSONResult deleteCourse(CourseDoc doc) {
                cause.printStackTrace();
                return JSONResult.error("搜索管理中心服务不可用!");
            }
        };
    }
}
